<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>地图导航</title>
    <style>
        *{
            margin:0;
            padding:0;
        }

        #container{
            width:100%;
            height:100vh;
            background-color:pink;
        }
    </style>
</head>
<body>
<div id="container"></div>
<script type="text/javascript">
    window._AMapSecurityConfig = {
      securityJsCode: "6e404b7e48be6c9c8fd63f0f88f31f0c",
    };
</script>
<script
        type="text/javascript"
        src="https://webapi.amap.com/maps?v=2.0&key=900d8f9be4304b89b2e8b4d9f45fd699"
></script>
<script type="text/javascript">
    //地图初始化应该在地图容器div已经添加到DOM树之后
    var zoom=18
    var map = new AMap.Map("container", {
      zoom: zoom,
      center:[110.397658,22.908028] ,//地图中心点坐标
    });
    function setLocation(lon,lat){
    map.setZoomAndCenter(zoom,[lon,lat])
    val marker=new AMap.Marker({
        map:map,
        icon:"https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png",
        position:[lon,lat]
    });
    map.add(marker)
    }
    map.plugin(['AMap.PlaceSearch'], function() {
    var PlaceSearchOptions = { //设置PlaceSearch属性
        map:map,
        pageSize: 4, //每页结果数,默认10
        pageIndex: 1, //请求页码，默认1
        extensions: "base" //返回信息详略，默认为base（基本信息）
    };
    var MSearch = new AMap.PlaceSearch(PlaceSearchOptions); //构造PlaceSearch类
    AMap.Event.addListener(MSearch, "complete", (result)=>{
    //调用鸿蒙端的方法，显示最近的几个地址
    window.swift.receiveNearPlace(JSON.stringify(result.poiList.pois))
    }); //返回结果
    MSearch. searchNearBy("停车场",[lon,lat]); //关键字查询
});
    window.onload=function(){
    //调用鸿蒙端的业务代码
    window.swift.setCurrentLocation()
    }

</script>
</body>
</html>